
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class RiskPredictionMapper extends Mapper<LongWritable, Text, IotData, NullWritable> {
	IotData iotData = new IotData();

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String line = value.toString();
		String[] split = line.split("\t");
		if (!"{\"lon\":\"0\",\"lat\":\"0\"}".equals(split[3])) {
			iotData.setAt(split[0]);
			iotData.setValue(split[3]);
			iotData.setDs_id(split[1]);
			iotData.setType(split[2]);
			iotData.setDev_id(split[4]);
			context.write(iotData, NullWritable.get());
		}

	}
}
